package com.ruoyi.libb.controller;

import com.ruoyi.libb.entity.Product;
import com.ruoyi.libb.service.ProductService;
import com.ruoyi.libb.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/product")
@Api(description="产品接口")
public class ProductController {
    @Resource
    private ProductService productService;

    @ApiOperation(value = "产品的列表")
    @RequestMapping("/productList")
    public Result productList(){

        return productService.productList();
    }


    @ApiOperation(value = "产品的添加")
    @PostMapping("/productSave")
    public Result productSave(@RequestBody Product product){


        return productService.productSave(product);
    }

    @ApiOperation(value = "产品的修改")
    @RequestMapping("/productUpdate")
    public Result productUpdate(@RequestBody Product product){


        return productService.productUpdate (product);
    }

    @RequestMapping("/productDelete")
    public Result productDelete(@ApiParam(name = "id", value = "产品ID", required = true) @RequestParam("id") Integer id){


        return productService.productDelete(id);
    }
}
